<template>
  <form>
    <el-input
      class="inputChange"
      v-model="userEmail_old"
      placeholder="请输入旧邮箱"
    />
    <el-input
      class="inputChange"
      v-model="userEmail_new1"
      placeholder="请输入新邮箱"
    />
    <el-input
      class="inputChange"
      v-model="userEmail_new2"
      placeholder="请再次输入新邮箱"
    />
    <el-button class="firstButton" type="primary" @click="emailChange"
      >提交</el-button
    >
    <el-button @click="emailNumberEmpty">清空</el-button>
  </form>
</template>

<script>
import axios from 'axios';
export default {
  name: "EmailChangeForm",
  data() {
    return {
      userEmail_old: "",
      userEmail_new1: "",
      userEmail_new2: "",
    };
  },
  methods: {
    emailChange() {
      var that = this;
      axios
        .post("WebApps/emailModification", {
          userEmail_origin: this.userEmail_old,
          newEmail_new1: this.userEmail_new1,
          newEmail_new2: this.userEmail_new2,
          token: this.$store.state.token,
        })
        .then(
          function (resp) {
            if (resp.data.code == 200) {
              that.$store.commit("setEmail", this.userEmail_new1);
              that.$message.success("修改成功");
            } else {
              that.$message.error("修改失败");
            }
          },
          function (err) {
            console.log(err);
          }
        );
    },
    emailNumberEmpty: function () {
      this.userEmailNumber_origin = "";
      this.userEmailNumber_new1 = "";
      this.userEmailNumber_new2 = "";
    },
  },
};
</script>

<style>
</style>